package JMU2.ti7;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @author Lenovo
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        ArrayList strList = new ArrayList();
        while(true){
            String s= scanner.next();
            if(!s.equals("!!end!!")){
                strList.add(s);
            }else break;
        }
        strList.add(0,"begin");
        strList.add("end");
        System.out.println(strList);
        String str= new String();
        str= scanner.next();
        System.out.println(strList.contains(str));
        System.out.println(strList.indexOf(str));
        System.out.println(strList.lastIndexOf(str));
        System.out.println(strList.get(0));
    }
}
